//
//  ViewController.m
//  午分享_map
//
//  Created by li cheng on 16/8/15.
//  Copyright © 2016年 li cheng. All rights reserved.
//

#import "ViewController.h"
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
@interface ViewController ()<MKMapViewDelegate>
@property (weak, nonatomic) IBOutlet MKMapView *myMKMapView;
@property (weak, nonatomic) IBOutlet UIButton *searchButton;
@property (weak, nonatomic) IBOutlet UIButton *positionButton;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    _myMKMapView.delegate = self;
    MKPointAnnotation *annottation = [[MKPointAnnotation alloc] init];
    annottation.coordinate = CLLocationCoordinate2DMake(31.2, 121.4);
    annottation.title = @"上海";
    annottation.subtitle = @"在这里";
    [_myMKMapView addAnnotation:annottation];
}
- (IBAction)shangHai:(id)sender {
    _myMKMapView.region = MKCoordinateRegionMake(CLLocationCoordinate2DMake(31.2, 121.4), MKCoordinateSpanMake(1, 1));
}

- (IBAction)location:(id)sender {
    CLLocation *location = _myMKMapView.userLocation.location;
    _myMKMapView.region = MKCoordinateRegionMake((location.coordinate), MKCoordinateSpanMake(1, 1));
    
}
- (nullable MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{
    MKAnnotationView *view = [[MKAnnotationView alloc] init];
    view.image = [UIImage imageNamed:@"123"];
    view.canShowCallout = YES;
    return view;
}
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
